package com.csot.ry.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.csot.common.annotation.Log;
import com.csot.common.core.controller.BaseController;
import com.csot.common.core.domain.AjaxResult;
import com.csot.common.enums.BusinessType;
import com.csot.ry.domain.TIpSegmentHistory;
import com.csot.ry.service.ITIpSegmentHistoryService;
import com.csot.common.utils.poi.ExcelUtil;
import com.csot.common.core.page.TableDataInfo;

/**
 * 历史信息查询Controller
 * 
 * @author 刘沙
 * @date 2022-06-01
 */
@RestController
@RequestMapping("/ipmanagement/history")
public class TIpSegmentHistoryController extends BaseController
{
    @Autowired
    private ITIpSegmentHistoryService tIpSegmentHistoryService;

    /**
     * 查询历史信息查询列表
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(TIpSegmentHistory tIpSegmentHistory)
    {
        startPage();
        List<TIpSegmentHistory> list = tIpSegmentHistoryService.selectTIpSegmentHistoryList(tIpSegmentHistory);
        return getDataTable(list);
    }

    /**
     * 导出历史信息查询列表
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:history:export')")
    @Log(title = "历史信息查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TIpSegmentHistory tIpSegmentHistory)
    {
        List<TIpSegmentHistory> list = tIpSegmentHistoryService.selectTIpSegmentHistoryList(tIpSegmentHistory);
        ExcelUtil<TIpSegmentHistory> util = new ExcelUtil<TIpSegmentHistory>(TIpSegmentHistory.class);
        util.exportExcel(response, list, "历史信息查询数据");
    }

    /**
     * 获取历史信息查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tIpSegmentHistoryService.selectTIpSegmentHistoryById(id));
    }

    /**
     * 新增历史信息查询
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:history:add')")
    @Log(title = "历史信息查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TIpSegmentHistory tIpSegmentHistory)
    {
        return toAjax(tIpSegmentHistoryService.insertTIpSegmentHistory(tIpSegmentHistory));
    }

    /**
     * 修改历史信息查询
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:history:edit')")
    @Log(title = "历史信息查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TIpSegmentHistory tIpSegmentHistory)
    {
        return toAjax(tIpSegmentHistoryService.updateTIpSegmentHistory(tIpSegmentHistory));
    }

    /**
     * 删除历史信息查询
     */
    @PreAuthorize("@ss.hasPermi('ipmanagement:history:remove')")
    @Log(title = "历史信息查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tIpSegmentHistoryService.deleteTIpSegmentHistoryByIds(ids));
    }
}
